#!/bin/bash

set -e

oem_mode=
if grep -q 'test-mode' /proc/cmdline; then
    oem_mode="oem-automatic"
else
    oem_mode="oem"
fi

cp -a /usr/share/applications/kylin-os-installer.desktop /etc/xdg/autostart || echo "kylin-os-installer.desktop is unexit" >>/var/log/installer/kylin-os-installer.log
sed -i "/Exec/d" /etc/xdg/autostart/kylin-os-installer.desktop
echo "Exec=/usr/bin/kylin-os-installer-${oem_mode}" >>/etc/xdg/autostart/kylin-os-installer.desktop

if [[ -f /etc/xdg/autostart/oem-qc.desktop ]]; then
      rm -f /etc/xdg/autostart/oem-qc.desktop
fi

if [[ -f /etc/xdg/autostart/oem-unlock.desktop ]]; then
        rm -f /etc/xdg/autostart/oem-unlock.desktop
fi
if [[ -f /usr/sbin/oem-unlock ]]; then
        rm -f /usr/sbin/oem-unlock
fi

